package bigDecimalTset;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.HashMap;

public class LocalDateTest {
    public static void main(String[] args) {
        localDateTest();
    }

    /**
     * LocalDate测试
     * 今天
     * 昨天
     * 明天
     * 本周的第一天
     * 本周的最后一天
     * 本月的第一天
     * 本月的最后一天
     * 上个的第一天
     * 上个的最后一天
     */
    public static void localDateTest() {
        //今天
        LocalDate today = LocalDate.now();
        System.out.println("今天：" + today);
        LocalDate localDate1 = today.plusWeeks(1);
        System.out.println(localDate1);

        //昨天
        LocalDate yesterday = today.minusDays(1);
        System.out.println("昨天：" + yesterday);
        //明天
        LocalDate localDate = today.plusDays(1);
        System.out.println("明天：" + localDate);
        // 获取本周的第一天（默认为周一.）
        LocalDate firstDayOfWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
        // 获取本周的最后一天（默认为周日）
        LocalDate lastDayOfWeek = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
        System.out.println("本周第一天：" + firstDayOfWeek);
        System.out.println("本周第最后一天：" + lastDayOfWeek);

        // 获取本月的第一天
        LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth());
        System.out.println("本月的第一天: " + firstDayOfMonth);

        // 获取本月的最后一天
        LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth());
        System.out.println("本月的最后一天: " + lastDayOfMonth);

        //获取上个的第一天
        LocalDate firstDayOfLastMonth = today.with(TemporalAdjusters.firstDayOfMonth()).minusMonths(1);
        System.out.println("上个的第一天: " + firstDayOfLastMonth);
        //获取上个月的最后一天
        LocalDate lastDayOfLastMonth = today.with(TemporalAdjusters.lastDayOfMonth()).minusMonths(1);
        System.out.println("上个月的最后一天: " + lastDayOfLastMonth);


        String s = new String("avc");
        System.out.println(s);
        int length = s.length();
        System.out.println(length);
        HashMap<String, String> map = new HashMap<>(8);
        HashMap<String, String> map1 = new HashMap<>();

    }
}
